<?php

namespace app\adminapi\controller\v1\office;

use app\adminapi\controller\AuthController;
use app\services\office\OfficeMajorService;
use think\facade\App;

class OfficeMajor extends AuthController
{

    public function __construct(App $app, OfficeMajorService $service)
    {
        parent::__construct($app);
        $this->services = $service;
    }

    public function index(){
        $where = $this->request->postMore([
            ['page', 1],
            ['pageSize', 20],
            ['website_id',$this  -> website],

        ]);
        return app() -> make('json') -> successful($this -> services -> index($where));
    }

    public function create(){
        $where = $this->request->postMore([
            ['title', ''],
            ['level', ''],
            ['major_code', ''],
            ['website_id',$this  -> website],
        ]);
        return app() -> make('json') -> successful($this -> services -> create($where));
    }

    public function update(){
        $where = $this->request->postMore([
            ['id', ''],
            ['title', ''],
            ['level', ''],
            ['major_code', ''],
        ]);
        return app() -> make('json') -> successful($this -> services -> update($where));
    }

    public function delete(){
        $where = $this->request->postMore([
            ['id', ''],
        ]);
        return app() -> make('json') -> successful($this -> services -> delete($where));
    }

    public function search(){
        $where = $this->request->postMore([
            ['title', ''],
            ['level', ''],
            ['major_code', ''],
            ['website_id',$this  -> website],
            ['page', 1],
            ['pageSize', 20],
        ]);
        return app() -> make('json') -> successful($this -> services -> search($where));
    }


}